\(\int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx\) [128]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 28, antiderivative size = 75 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {\frac {1}{a}+\frac {a}{b^2}}{d (b+a \cot (c+d x))}-\frac {2 a \log (b+a \cot (c+d x))}{b^3 d}-\frac {2 a \log (\tan (c+d x))}{b^3 d}+\frac {\tan (c+d x)}{b^2 d} \]

[Out]

(1/a+a/b^2)/d/(b+a*cot(d*x+c))-2*a*ln(b+a*cot(d*x+c))/b^3/d-2*a*ln(tan(d*x+c))/b^3/d+tan(d*x+c)/b^2/d

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.071, Rules used = {3167, 908} \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {2 a \log (\tan (c+d x))}{b^3 d}-\frac {2 a \log (a \cot (c+d x)+b)}{b^3 d}+\frac {\frac {a}{b^2}+\frac {1}{a}}{d (a \cot (c+d x)+b)}+\frac {\tan (c+d x)}{b^2 d} \]

[In]

Int[Sec[c + d*x]^2/(a*Cos[c + d*x] + b*Sin[c + d*x])^2,x]

[Out]

(a^(-1) + a/b^2)/(d*(b + a*Cot[c + d*x])) - (2*a*Log[b + a*Cot[c + d*x]])/(b^3*d) - (2*a*Log[Tan[c + d*x]])/(b
^3*d) + Tan[c + d*x]/(b^2*d)

Rule 908

Int[((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_))^(n_)*((a_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIn
tegrand[(d + e*x)^m*(f + g*x)^n*(a + c*x^2)^p, x], x] /; FreeQ[{a, c, d, e, f, g}, x] && NeQ[e*f - d*g, 0] &&
NeQ[c*d^2 + a*e^2, 0] && IntegerQ[p] && ((EqQ[p, 1] && IntegersQ[m, n]) || (ILtQ[m, 0] && ILtQ[n, 0]))

Rule 3167

Int[cos[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symb
ol] :> Dist[-d^(-1), Subst[Int[x^m*((b + a*x)^n/(1 + x^2)^((m + n + 2)/2)), x], x, Cot[c + d*x]], x] /; FreeQ[
{a, b, c, d}, x] && IntegerQ[n] && IntegerQ[(m + n)/2] && NeQ[n, -1] &&  !(GtQ[n, 0] && GtQ[m, 1])

Rubi steps \begin{align*} \text {integral}& = -\frac {\text {Subst}\left (\int \frac {1+x^2}{x^2 (b+a x)^2} \, dx,x,\cot (c+d x)\right )}{d} \\ & = -\frac {\text {Subst}\left (\int \left (\frac {1}{b^2 x^2}-\frac {2 a}{b^3 x}+\frac {a^2+b^2}{b^2 (b+a x)^2}+\frac {2 a^2}{b^3 (b+a x)}\right ) \, dx,x,\cot (c+d x)\right )}{d} \\ & = \frac {\frac {1}{a}+\frac {a}{b^2}}{d (b+a \cot (c+d x))}-\frac {2 a \log (b+a \cot (c+d x))}{b^3 d}-\frac {2 a \log (\tan (c+d x))}{b^3 d}+\frac {\tan (c+d x)}{b^2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.27 (sec) , antiderivative size = 51, normalized size of antiderivative = 0.68 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {-2 a \log (a+b \tan (c+d x))+b \tan (c+d x)-\frac {a^2+b^2}{a+b \tan (c+d x)}}{b^3 d} \]

[In]

Integrate[Sec[c + d*x]^2/(a*Cos[c + d*x] + b*Sin[c + d*x])^2,x]

[Out]

(-2*a*Log[a + b*Tan[c + d*x]] + b*Tan[c + d*x] - (a^2 + b^2)/(a + b*Tan[c + d*x]))/(b^3*d)

Maple [A] (verified)

Time = 1.08 (sec) , antiderivative size = 57, normalized size of antiderivative = 0.76

method result size
derivativedivides \(\frac {\frac {\tan \left (d x +c \right )}{b^{2}}-\frac {a^{2}+b^{2}}{b^{3} \left (a +b \tan \left (d x +c \right )\right )}-\frac {2 a \ln \left (a +b \tan \left (d x +c \right )\right )}{b^{3}}}{d}\) \(57\)
default \(\frac {\frac {\tan \left (d x +c \right )}{b^{2}}-\frac {a^{2}+b^{2}}{b^{3} \left (a +b \tan \left (d x +c \right )\right )}-\frac {2 a \ln \left (a +b \tan \left (d x +c \right )\right )}{b^{3}}}{d}\) \(57\)
risch \(-\frac {4 i \left (-i a \,{\mathrm e}^{2 i \left (d x +c \right )}+b -i a \right )}{\left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right ) b^{2} d}+\frac {2 a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{b^{3} d}-\frac {2 a \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right )}{b^{3} d}\) \(136\)
parallelrisch \(\frac {-2 a \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a \right )+2 a \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+2 a \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+\left (-2 a^{2}-2 b^{2}\right ) \cos \left (2 d x +2 c \right )-2 a^{2}}{b^{3} d \left (a \cos \left (2 d x +2 c \right )+a +b \sin \left (2 d x +2 c \right )\right )}\) \(196\)
norman \(\frac {\frac {\left (4 a^{2}+6 b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}{b^{3} d}-\frac {4 a^{2}+2 b^{2}}{2 b^{3} d}-\frac {\left (4 a^{2}+2 b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}}{2 b^{3} d}}{\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right ) \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a \right )}+\frac {2 a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{b^{3} d}+\frac {2 a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{b^{3} d}-\frac {2 a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a \right )}{b^{3} d}\) \(209\)

[In]

int(sec(d*x+c)^2/(cos(d*x+c)*a+b*sin(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(tan(d*x+c)/b^2-1/b^3*(a^2+b^2)/(a+b*tan(d*x+c))-2*a/b^3*ln(a+b*tan(d*x+c)))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 178 vs. \(2 (75) = 150\).

Time = 0.27 (sec) , antiderivative size = 178, normalized size of antiderivative = 2.37 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {2 \, b^{2} \cos \left (d x + c\right )^{2} - 2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) - b^{2} + {\left (a^{2} \cos \left (d x + c\right )^{2} + a b \cos \left (d x + c\right ) \sin \left (d x + c\right )\right )} \log \left (2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}\right ) - {\left (a^{2} \cos \left (d x + c\right )^{2} + a b \cos \left (d x + c\right ) \sin \left (d x + c\right )\right )} \log \left (\cos \left (d x + c\right )^{2}\right )}{a b^{3} d \cos \left (d x + c\right )^{2} + b^{4} d \cos \left (d x + c\right ) \sin \left (d x + c\right )} \]

[In]

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="fricas")

[Out]

-(2*b^2*cos(d*x + c)^2 - 2*a*b*cos(d*x + c)*sin(d*x + c) - b^2 + (a^2*cos(d*x + c)^2 + a*b*cos(d*x + c)*sin(d*
x + c))*log(2*a*b*cos(d*x + c)*sin(d*x + c) + (a^2 - b^2)*cos(d*x + c)^2 + b^2) - (a^2*cos(d*x + c)^2 + a*b*co
s(d*x + c)*sin(d*x + c))*log(cos(d*x + c)^2))/(a*b^3*d*cos(d*x + c)^2 + b^4*d*cos(d*x + c)*sin(d*x + c))

Sympy [F]

\[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\int \frac {\sec ^{2}{\left (c + d x \right )}}{\left (a \cos {\left (c + d x \right )} + b \sin {\left (c + d x \right )}\right )^{2}}\, dx \]

[In]

integrate(sec(d*x+c)**2/(a*cos(d*x+c)+b*sin(d*x+c))**2,x)

[Out]

Integral(sec(c + d*x)**2/(a*cos(c + d*x) + b*sin(c + d*x))**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.22 (sec) , antiderivative size = 60, normalized size of antiderivative = 0.80 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {a^{2} + b^{2}}{b^{4} \tan \left (d x + c\right ) + a b^{3}} + \frac {2 \, a \log \left (b \tan \left (d x + c\right ) + a\right )}{b^{3}} - \frac {\tan \left (d x + c\right )}{b^{2}}}{d} \]

[In]

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="maxima")

[Out]

-((a^2 + b^2)/(b^4*tan(d*x + c) + a*b^3) + 2*a*log(b*tan(d*x + c) + a)/b^3 - tan(d*x + c)/b^2)/d

Giac [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 71, normalized size of antiderivative = 0.95 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {2 \, a \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{b^{3}} - \frac {\tan \left (d x + c\right )}{b^{2}} - \frac {2 \, a b \tan \left (d x + c\right ) + a^{2} - b^{2}}{{\left (b \tan \left (d x + c\right ) + a\right )} b^{3}}}{d} \]

[In]

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="giac")

[Out]

-(2*a*log(abs(b*tan(d*x + c) + a))/b^3 - tan(d*x + c)/b^2 - (2*a*b*tan(d*x + c) + a^2 - b^2)/((b*tan(d*x + c)
+ a)*b^3))/d

Mupad [B] (verification not implemented)

Time = 24.40 (sec) , antiderivative size = 382, normalized size of antiderivative = 5.09 \[ \int \frac {\sec ^2(c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {\frac {4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b}-\frac {2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,\left (2\,a^2+b^2\right )}{a\,b^2}+\frac {2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (2\,a^2+b^2\right )}{a\,b^2}}{d\,\left (a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-2\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-2\,a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+2\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+a\right )}-\frac {4\,a\,\mathrm {atanh}\left (\frac {64\,a^3\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{64\,a^3-64\,a^3\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+\frac {128\,a^5}{b^2}-\frac {128\,a^5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b^2}+\frac {128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{b}}-\frac {64\,a^3}{64\,a^3-64\,a^3\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+\frac {128\,a^5}{b^2}-\frac {128\,a^5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b^2}+\frac {128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{b}}+\frac {128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{64\,a^3\,b+\frac {128\,a^5}{b}+128\,a^4\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )-\frac {128\,a^5\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{b}-64\,a^3\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}\right )}{b^3\,d} \]

[In]

int(1/(cos(c + d*x)^2*(a*cos(c + d*x) + b*sin(c + d*x))^2),x)

[Out]

((4*tan(c/2 + (d*x)/2)^2)/b - (2*tan(c/2 + (d*x)/2)^3*(2*a^2 + b^2))/(a*b^2) + (2*tan(c/2 + (d*x)/2)*(2*a^2 +
b^2))/(a*b^2))/(d*(a + 2*b*tan(c/2 + (d*x)/2) - 2*a*tan(c/2 + (d*x)/2)^2 + a*tan(c/2 + (d*x)/2)^4 - 2*b*tan(c/
2 + (d*x)/2)^3)) - (4*a*atanh((64*a^3*tan(c/2 + (d*x)/2)^2)/(64*a^3 - 64*a^3*tan(c/2 + (d*x)/2)^2 + (128*a^5)/
b^2 - (128*a^5*tan(c/2 + (d*x)/2)^2)/b^2 + (128*a^4*tan(c/2 + (d*x)/2))/b) - (64*a^3)/(64*a^3 - 64*a^3*tan(c/2
 + (d*x)/2)^2 + (128*a^5)/b^2 - (128*a^5*tan(c/2 + (d*x)/2)^2)/b^2 + (128*a^4*tan(c/2 + (d*x)/2))/b) + (128*a^
4*tan(c/2 + (d*x)/2))/(64*a^3*b + (128*a^5)/b + 128*a^4*tan(c/2 + (d*x)/2) - (128*a^5*tan(c/2 + (d*x)/2)^2)/b
- 64*a^3*b*tan(c/2 + (d*x)/2)^2)))/(b^3*d)